README

This is the replication file collection for "Do democracies select more experienced leaders? Introducing the PolEx measure of political experience".

R (using RStudio and packages such as RStan and ggplot2) was used for the main latent variable model and some of the figures. Stata was used for additional figures and data analysis. All code files and files used as input data are provided in this replication package, as outlined below.

To replicate the analysis, execute scripts in this order:

1) create polexp group vars.R
2) latent_variable_model.R

This generates the PolEx estimates, which can subsequently be visualised or analysed, in no particular order, with:

- average_over_time_plot.R
- latent_variable_plots.R
- forest.R
- PolEx_map.R
- make_posts_by_regime_diff.do
- estimations_appendix.do


FILE OVERVIEW

age and education graphs.R: R code to produce Figure 3 in the appendix.
average_over_time_plot.R: R code to produce a time-series plot of average PolEx scores, Figure 6, as well as Figure 1 in the appendix. Figures 4, 5, 7 and 9 in the appendix can be reproduced in analogous fashion.
cats.dta: Stata file with categorisation of posts used in Stata do files.
compare_separate_vs_joint_model.R: R code to produce Figure 10 in the appendix.
create polexp group vars.R and polex_cats.txt: R code and a plain text input file that was used to generate the input variables of the latent variable model based on our data on political careers of leaders.
estimation_gamma_vars.dta: This Stata file is the full data set that includes data about careers and posts of political leaders as well as PolEx (gamma) scores and the estimates of uncertainty. This file is a merged data set of the input data of the latent variable model and the output estimates, but can also be used as input in the first place to repeat the estimation.
estimations_appendix.do and Log_appendix.smcl: Stata do-file and log-file containing much of the analyses in the supplementary appendix to the paper, in particular tables 4, 5, 7-10, 13 and figures 6 and 8.
item_response_curves.R: R code to generate the item response curves in Figure 3 and Figure 11 in the appendix.
latent_variable_model.R: R code implementing the estimation of the PolEx latent variable model, under a range of specifications. See comments at the beginning of the file for instructions on the arguments that can be passed, to identify different model formulations. The end result is a Stata file such as the included estimation_gamma_vars.dta.
latent_variable_plots.R: R code to produce a range of figures providing insight into the estimated latent variable model. Most of these plots are for diagnostics and inspection only, but one of the plots produced by this script is Figure 5.
lines styles.R: R utility code to standardize selection of line styles and colors in figures.
PolEx.dta: Data file with the PolEx estimates and uncertainty estimates, for readers who want to use the PolEx in their empirical research.
PolEx_map.R: R code to generate the map in Figure 4 and Figure 2 in the appendix.
gamma2017.dta: Data file used in the R code for generating the map in Figure 4.
meangamma.dta: Data file used in the R code for generating the map in Figure 2 in the appendix.
posts_by_diff.dta, make_posts_by_regime_diff.xlsx and make_posts_by_regime_diff.do: Stata code used to produce Figure 1, including Excel file that was generated in the intermediate step to transpose the data, as well as the summary data set used to produce Figure 1.

